$(function () {

    //AJAX发送页数信息
    let parameters = getQueryVariable();
    let page = parameters["page"];
    let keyword = decodeURIComponent(parameters["keyword"]);
    let model = parameters["model"];
    console.log(keyword);
    if (parameters["keyword"] == null){
        $.get("book/all", page, function (result) {
            let bookList = result["list"];
            let size = result["size"]
            setGoodsList(bookList, size)
            setPageNav(result);
        }, 'json');
    } else {
        let url;
        if(model === 0){
            url = "book/search/byname";
        } else {
            url = "book/search/byauthor";
        }
        let data = {page:page, keyword:keyword};
        console.log(data);
        $.get(url, data, function (result) {
            let bookList = result["list"];
            let size = result["size"];
            let keywordInputDom = $("#keywordInput");
            keywordInputDom.val(keyword);
            setGoodsList(bookList, size)
            showPageNavWithKeyword(result, keyword);
            // 遍历参数
            for (let key in result) {
                console.log(key);
                console.log(result[key]);
            }
        }, 'json');
    }

});